package com.smartplatform.dto;

import com.smartplatform.constants.ResultCode;
import lombok.Data;
import lombok.ToString;

/**
 * @Author 咕唧
 * @Date 2022/5/26 12:44
 * @Version 1.0
 */
@Data
@ToString
public class R {
    private int code;
    private String msg;
    private Object result;

    public static R setOK() {
        return setOK(null);
    }

    public static R setOK(Object result) {
        return setResult(ResultCode.SUCCESS, "成功", result);
    }

    public static R setError() {
        return setError(null);
    }

    public static R setError(Object result) {
        return setResult(ResultCode.ERROR, "失败", result);
    }

    public  static R setResult(int code, String msg, Object result) {
        R r = new R();
        r.setCode(code);
        r.setMsg(msg);
        r.setResult(result);
        return r;
    }
}
